package soen6441;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Comments {
    static final String multiLineComment = "/\\*.*?\\*/";
    static final String singleLineComment = "//[^\\n]*\\n";

    static String remove(String oldContent) {
        String newContent = oldContent;

        // replace all multi line comments
        Pattern multiLineCommentPattern
                = Pattern.compile(multiLineComment);

        Matcher multiLineComment
                = multiLineCommentPattern.matcher(newContent);

        newContent = multiLineComment.replaceAll("");

        // replace all single line comments
        Pattern singleLineCommentPattern =
                Pattern.compile(singleLineComment);

        Matcher singleLineComment =
                singleLineCommentPattern.matcher(newContent);

        newContent = singleLineComment.replaceAll("\n");

        return newContent;
    }
}
